import request from '@/utils/request'

// 添加企业
export function addEnterprise(data) {
  return request({
    url: '/business/company/save',
    method: 'post',
    data
  })
}

// 分页查询企业信息
export function searchEnterprise(pageNum, pageSize, name, contactsName, offset) {
  console.log({ pageNum, pageSize, name, contactsName, offset })
  return request({
    url: '/business/company/getPage',
    params: {
      name,
      pageNum,
      pageSize,
      contactsName,
      offset
    }
  })
}

// 查询企业名称是否存在
export function isTheCompanyNameDuplicate(name) {
  return request({
    url: '/business/company/repeat',
    params: name
  })
}

// 获取所有企业名称
export function getAllEnterpriseName() {
  return request({
    url: '/business/company/getCompanyNames'
  })
}

// 编辑企业信息
export function editEnterpriseInfo(data) {
  console.log(data)
  return request({
    url: '/business/company/edit',
    method: 'post',
    data
  })
}

// 根据ID获取企业详情
export function getEnterpriseDetailByID(id) {
  console.log(id)
  return request({
    url: '/business/company/getDetailsById',
    params: id
  })
}

// 批量删除企业
export function deleteEnterprise(data) {
  return request({
    url: '/business/company/delete',
    method: 'post',
    data
  })
}

// 下载列表
export function companyexportlist(data) {
  return request({
    url: '/business/company/export',
    params: data,
    responseType: 'blob'
  })
}

// 新增货物类型
export function addGoodsType(goodType) {
  return request({
    url: '/business/goodsType/createGoodsType',
    params: goodType
  })
}

// 获取货物类型下拉框
export function getGoodsType() {
  return request({
    url: '/business/goodsType/getGoodsType'
  })
}
